using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace tutors_clus.Models.Mapping
{
    public class messageMap : EntityTypeConfiguration<message>
    {
        public messageMap()
        {
            // Primary Key
            this.HasKey(t => t.id_mes);

            // Properties
            this.Property(t => t.title_mes)
                .HasMaxLength(200);

            // Table & Column Mappings
            this.ToTable("messages");
            this.Property(t => t.id_mes).HasColumnName("id_mes");
            this.Property(t => t.id_cou).HasColumnName("id_cou");
            this.Property(t => t.id_stu).HasColumnName("id_stu");
            this.Property(t => t.title_mes).HasColumnName("title_mes");
            this.Property(t => t.content_mes).HasColumnName("content_mes");
            this.Property(t => t.createdate_msg).HasColumnName("createdate_msg");
            this.Property(t => t.parent).HasColumnName("parent");
            this.Property(t => t.isrepply).HasColumnName("isrepply");

            // Relationships
            this.HasOptional(t => t.course)
                .WithMany(t => t.messages)
                .HasForeignKey(d => d.id_cou);
            this.HasOptional(t => t.student)
                .WithMany(t => t.messages)
                .HasForeignKey(d => d.id_stu);

        }
    }
}
